﻿/**********************************************************************
 * @file   GraphVTKObjectPartMesh.h
 * @brief  part网格渲染对象
 * @author ZhouZhaoYi (zhouzhaoyi@diso.cn)
 * @date   2025-07-18
 *********************************************************************/
#ifndef _GRAPHVTKOBJECTPARTMESH_H__
#define _GRAPHVTKOBJECTPARTMESH_H__

#include "GraphDataVTKAdaptorAPI.h"
#include "GraphVTKObjectModelBase.h"

namespace Radioss
{
    class FITKRadiossPart;
}
namespace Interface {
    class FITKMeshFeatureVTK;
}
class vtkUnstructuredGrid;
class vtkDataSetSurfaceFilter;
class RadiossVTKGraphActor;
namespace Exchange {

    /**
     * @brief  part网格渲染对象
     * @author ZhouZhaoYi (zhouzhaoyi@diso.cn)
     * @date   2025-07-18
     */
    class GraphDataVTKAdaptorAPI GraphVTKObjectPartMesh : public GraphVTKObjectModelBase
    {
        Q_OBJECT;
        FITKGraphObjectRegist(GraphVTKObjectPartMesh, GraphVTKObjectModelBase);
        FITKCLASS(Exchange, GraphVTKObjectPartMesh);
    public:
        /**
         * @brief  构造函数
         * @author ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date   2025-07-18
         */
        GraphVTKObjectPartMesh(Radioss::FITKRadiossPart* dataObj);
        /**
         * @brief  析构函数
         * @author ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date   2025-07-18
         */
        virtual ~GraphVTKObjectPartMesh();
        /**
         * @brief    更新
         * @param[i] forceUpdate 是否强制刷新
         * @author   ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date     2025-07-21
         */
        virtual void update(bool forceUpdate = false) override;
        /**
         * @brief    获取数据可见
         * @return   bool 是否可见
         * @author   ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date     2025-07-21
         */
        virtual bool getVisibility() override;
        /**
         * @brief  更新可见
         * @author ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date   2025-07-21
         */
        virtual void updateVisibility() override;
        /**
         * @brief    更新模型颜色
         * @param[i] color                    颜色
         * @author   ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date     2025-07-21
         */
        virtual void updateModelColor(QColor color) override;
        /**
         * @brief    设置点大小
         * @param[i] size 
         * @return   void
         * @author   ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date     2025-09-15
         */
        virtual void updatePointSize(int size) override;
        /**
         * @brief    设置线宽
         * @param[i] width 
         * @author   ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date     2025-09-15
         */
        virtual void updateLineWidth(int width) override;
        /**
         * @brief    设置透明度
         * @param[i] opacity 
         * @author   ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date     2025-09-15
         */
        virtual void updateOpacity(double opacity) override;
        /**
         * @brief    设置渲染模式
         * @param[i] arg 
         * @author   ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date     2025-09-15
         */
        virtual void updateRepresentation(int arg) override;
        /**
         * @brief    模型显示隐藏
         * @param[i] visibility 
         * @return   void
         * @author   ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date     2025-09-25
         */
        virtual void setVisible(bool visibility) override;
        /**
         * @brief    设置单元显示隐藏
         * @param[i] visibility 
         * @return   void
         * @author   ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date     2025-09-24
         */
        virtual void setCellVisible(bool visibility) override;
        /**
         * @brief    设置点演员隐藏还是显示
         * @param[i] visibility 
         * @author   ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date     2025-09-15
         */
        virtual void setPointVisibility(bool visibility)override;
        /**
         * @brief    设置线演员隐藏还是显示
         * @param[i] visibility 
         * @author   ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date     2025-09-22
         */
        virtual void setLineVisibility(bool visibility)override;
        /**
         * @brief    设置拾取模式
         * @param[i] mode                        拾取模式
         * @author   ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date     2025-08-05
         */
        virtual void setPickMode(GraphVTKCommons::ShapePickMode mode) override;
        /**
         * @brief    根据给定的形状类型与VTK单元id获取形状ID
         * @param[i] vtkCellId                      VTK单元ID
         * @param[i] pickType                       拾取类型
         * @return   int                            形状ID
         * @return   otherInfo                      缺省参数
         * @author   ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date     2025-08-05
         */
        virtual int getShapeIdByVTKCellId(int vtkCellId, GraphVTKCommons::ShapePickMode pickType, QVariant otherInfo = QVariant()) override;
        /**
         * @brief    通过表面单元id获取表面单元面的索引
         * @param[i] vtkCellSurfId                  VTK表面单元id
         * @param[i] pickType                       拾取类型
         * @return   int                            VTK表面索引
         * @author   ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date     2025-08-05
         */
        virtual int getEleSurfIndexByEleSurfCellID(int vtkCellSurfId, GraphVTKCommons::ShapePickMode pickType) override;
        /**
         * @brief    更具给定的形状类型与形状id，获取VTK单元id
         * @param[i] shapeId                        形状id
         * @param[i] pickType                       拾取类型
         * @return   const QVector<int>             单元id
         * @return   otherInfo                      缺省参数
         * @author   ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date     2025-08-05
         */
        virtual const QVector<int> getVTKCellIdsByShapeId(int shapeId, GraphVTKCommons::ShapePickMode pickType, QVariant otherInfo = QVariant()) override;
        /**
         * @brief    根据形状网格类型获取网格数据
         * @param[i] type                           形状网格类型
         * @return   vtkDataSet*                    拾取类型
         * @author   ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date     2025-08-05
         */
        virtual vtkDataSet* getMesh(GraphVTKCommons::ShapePickMode pickType) override;
        /**
         * @brief    获取网格特征对象
         * @return   Interface::FITKMeshFeatureVTK *
         * @author   ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date     2025-08-06
         */
        Interface::FITKMeshFeatureVTK* getMeshFeature() const;

    protected:
        /**
         * @brief  初始化
         * @author ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date   2025-07-21
         */
        void init();
        /**
         * @brief  初始化演员
         * @author ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date   2025-07-21
         */
        void initActor();
        /**
         * @brief  更新数据
         * @author ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date   2025-07-21
         */
        bool updateGraphData();

    private:
        /**
         * @brief    创建单元
         * @return   void
         * @author   ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date     2025-07-23
         */
        void createCellGrid();
        /**
         * @brief    创建节点
         * @author   ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date     2025-07-23
         */
        void createVertexGrid();
        /**
         * @brief    创建表面节点
         * @author   ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date     2025-07-23
         */
        void createSurfPointGrid();
    private:
        /**
         * @brief  网格演员
         * @author ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date   2025-07-21
         */
        RadiossVTKGraphActor* _meshCellActor = nullptr;
        RadiossVTKGraphActor* _meshVertexActor = nullptr;
        RadiossVTKGraphActor* _meshSurfCellActor = nullptr;
        RadiossVTKGraphActor* _meshSurfNodeActor = nullptr;

        /**
         * @brief  网格数据
         * @author ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date   2025-07-21
         */
        vtkUnstructuredGrid* _meshCellData = nullptr;
        vtkUnstructuredGrid* _meshVertexData = nullptr;
        vtkUnstructuredGrid* _meshSurfPointData = nullptr;
        /**
         * @brief  网格特征
         * @author ZhouZhaoYi (zhouzhaoyi@diso.cn)
         * @date   2025-07-21
         */
        Interface::FITKMeshFeatureVTK* _meshFeature = nullptr;
    };
}

#endif // !_GRAPHVTKOBJECTPARTMESH_H__
